<template>
  <div class="app-container"  style="height: 100%;">
    <el-divider content-position="left">【专项债券储备申报模拟】</el-divider>
    <el-row>
      <el-button type="primary" @click="handleAdd()">模拟新增填报</el-button>
      <el-button type="primary" @click="handleEdit()">模拟修改填报</el-button>
      <el-form inline style="margin-left: 12px;">
        <el-form-item label="储备项目ID">
          <el-input style="width: 300px;" v-model="specialProId" placeholder="请输入储备项目ID" />
        </el-form-item>
        <el-form-item label="储备项目表单ID">
          <el-input style="width: 300px;" v-model="specialFormId" placeholder="请输入储备项目ID" />
        </el-form-item>
      </el-form>
    </el-row>
    <el-divider content-position="left">【一般债券储备申报模拟】</el-divider>
    <el-row>
      <el-button type="primary" @click="handleAdd1()">模拟新增填报</el-button>
      <el-button type="primary" @click="handleEdit1()">模拟修改填报</el-button>
      <el-form inline style="margin-left: 12px;">
        <el-form-item label="储备项目ID">
          <el-input style="width: 300px;" v-model="genericProId" placeholder="请输入储备项目ID" />
        </el-form-item>
        <el-form-item label="储备项目表单ID">
          <el-input style="width: 300px;" v-model="genericFormId" placeholder="请输入储备项目ID" />
        </el-form-item>
      </el-form>
    </el-row>
    <el-divider content-position="left">【债券备选项目申报模拟】</el-divider>
    <el-row>
      <el-button type="primary" @click="handleAdd2()">模拟新增填报</el-button>
      <el-button type="primary" @click="handleEdit2()">模拟修改填报</el-button>
      <el-form inline style="margin-left: 12px;">
        <el-form-item label="储备项目ID">
          <el-input style="width: 300px;" v-model="selectProId" placeholder="请输入储备项目ID" />
        </el-form-item>
        <el-form-item label="储备项目表单ID">
          <el-input style="width: 300px;" v-model="selectProType" placeholder="请输入储备项目ID" />
        </el-form-item>
        <el-form-item label="备选项目表单ID">
          <el-input style="width: 300px;" v-model="standbyFormId" placeholder="请输入储备项目ID" />
        </el-form-item>
      </el-form>
    </el-row>
    <!-- 对应的是专项债券储备申报模拟-->
    <ReserveProjDialog
      ref="reserveGenericProjDialogRef"
      type="generic"
      :formId="genericFormId"
      :processKey="processKey"
    />
    <ReserveProjDialog
      ref="reserveSpecialProjDialogRef"
      type="special"
      :formId="specialFormId"
      :processKey="processKey"
    />
    <ReserveProjDialog
      ref="standbyProjDialogRef"
      type="standby"
      :formId="standbyFormId"
      :processKey="processKey"
    />
  </div>
</template>

<script setup name="XmFillingView">
import { useRoute } from 'vue-router'

import ReserveProjDialog from '@/components/form/business/ReserveProjDialog.vue'


// ----- 从当前路由中取参数
const route = useRoute()
console.log('route', route.query)

// 专项储备项目ID
const specialProId = ref('A6EB16815DC4406EA349FA53CBE200D9')
// 专项储备项目的表单ID
const specialFormId = ref('A36E16E049794F2F88D2C6651F2D6FC3')
// 流程标识
const processKey = ref('PRO_CBK')

// 一般储备项目ID
const genericProId = ref('9EACF40B7A76442B85C02EE4AC4C8E4F')
// 一般储备项目的表单ID
const genericFormId = ref('A0C89DA422604CD6B7A6EBE20D0A3761')

// 基本信息
const baseInfo = reactive({
  // 选中项目ID
  proId: '',
  // 选中区划编码
  adCode: '2300',
  // 单位ID
  agId: '3AC80CEBBFF4EE0B1CEF5E28FF1136A',
  // 选中单位编码
  agCode: '505',
  // 单位名称
  agName: '230103505单位',
  // 项目来源：1：基础库 2：储备库 3:需求库 4：历史项目 5、一体化同步项目 6、存量债务无项目生成项目
  proSource: '2',
})

// ----- 专项项目填报示例
const reserveSpecialProjDialogRef = ref()
/**
 * 添加项目
 */
const handleAdd = () => {
  const addInfo = toRaw(baseInfo)
  reserveSpecialProjDialogRef.value.handleAdd(addInfo)
}
/**
 * 修改项目
 */
const handleEdit = () => {
  const editInfo = toRaw(baseInfo)
  editInfo.proId = specialProId.value
  reserveSpecialProjDialogRef.value.handleEdit(editInfo)
}


// ----- 一般项目填报示例
const reserveGenericProjDialogRef = ref()
/**
 * 添加项目
 */
const handleAdd1 = () => {
  const addInfo = toRaw(baseInfo)
  reserveGenericProjDialogRef.value.handleAdd(addInfo)
}
/**
 * 修改项目
 */
const handleEdit1 = () => {
  const editInfo = toRaw(baseInfo)
  editInfo.proId = genericProId.value
  reserveGenericProjDialogRef.value.handleEdit(editInfo)
}


const standbyProjDialogRef = ref()
// 储备项目ID
const selectProId = ref('897BC30154504513BBEEC2BDC5F53591')
// 储备项目类型 sp-专项项目 ge-一般项目
const selectProType = ref('sp')
// 备选项目的表单ID
const standbyFormId = '5FD8F682CD8446DEA55D4AD3DA7D3909'
const handleAdd2 = () => {
  const addInfo = toRaw(baseInfo)
  addInfo.proId = selectProId.value
  addInfo.proType = 'sp'
  standbyProjDialogRef.value.handleAdd(addInfo)
}

/**
 * 修改项目
 */
const handleEdit2 = () => {
  const editInfo = toRaw(baseInfo)
  addInfo.proId = selectProId.value
  standbyProjDialogRef.value.handleEdit(editInfo)
}

</script>

<style lang="scss" scoped>
</style>

<style lang="scss">
</style>
